﻿<style type="text/css">
    /*聊天列表*/
    .news-bottom{z-index:0;margin-top:6px;}
    .news-bottom ul li{display:-webkit-box;border-bottom: 1px solid #f2f2f2;clear: both;position: relative;}
    .news-bottom ul li .news-pic{margin-left: 15px;margin-top:5px;}
    .news-bottom ul li .news-pic img{width: 50px;height: 50px;display: inline-block;border-radius: 5px;}
    .news-cont{margin: 5px 0px 6px 10px;-webkit-box-flex: 1;}
    .news-cont h2{font-size: 16px;display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;font-weight: 700;margin-right: 100px;}
    .news-cont p{display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;font-size: 14px;color: #999;margin-top: 5px;margin-right: 15px;}
    .news-time{position: absolute;top:13px;right: 13px;color: #ccc;}
    .news-time a{padding-top: 5px;padding-bottom: 5px;width:50px;text-align:center;background:#4e6097;color: #fff;display: inline-block;border-radius: 5px;display:inline-block;}
</style>
<div class="news-bottom">
    <ul>
        <li v-for="data in bag.datas" v-cloak="">
            <div class="news-pic" v-on:click="detail(data.sourceid)">
                <img :src="data.sourceicon">
            </div>
            <div class="news-cont">
                <h2 v-text="data.srouceusername">-</h2>
                <p v-text="data.explain">-</p>
            </div>
            <span class="news-time" v-if="data.state == 1">
                <a v-on:click="pass(data.id,data.srouceusername)">同意</a>
                <a v-on:click="reject(data.id,data.srouceusername)" style="background:#bbb">拒绝</a>
            </span>
            <span class="news-time" v-if="data.state != 1" v-text="'已'+data.statename"></span>
        </li>
    </ul>
</div>
<div style="text-align:center;margin-top:0.5em;" v-if="bag.dataend == false" v-cloak="">
    <a v-on:click="more" v-text="morename" style="color:#888;">-</a>
</div>
<div style="text-align:center;margin-top:0.5em;" v-if="bag.dataend == true" v-cloak="">
    <a style="color:#aaa;">已显示所有</a>
</div>
<div style="height:60px;"></div>
<script type="text/javascript">
    var pagedata = {
        request: {
            method: "VIEW_FRIEND_APPLYLISTS",
            page: 0,
        },
        screen: {
            header_display: true,
            footer_choose: "friend",
            header_title_name: "新的朋友",
            header_exit_name: "返回",
            header_exit_click: function () {
                mview.view.load('/views/module/friend/relationlists.html');
            }
        },
        data: {
            morename: "查看更多"
        },
        methods: {
            pass: function (id, title) {
                mview.control.confirm("提示", "同意与" + title + "成为为好友", function () {
                    mview.socket.send({
                        data: {
                            method: "FRIEND_RELATION_PASS",
                            id: id
                        },
                        success: function (data) {
                            if (data.Code == 0) {
                                mview.control.tips("已同意");
                                pagedata.reload();
                            }
                            else {
                                mview.control.tips(data.Message);
                            }
                        }
                    });
                });
            },
            reject: function (id, title) {
                mview.control.confirm("提示", "您将拒绝与" + title + "成为为好友", function () {
                    mview.socket.send({
                        data: {
                            method: "FRIEND_RELATION_REJECT",
                            id: id
                        },
                        success: function (data) {
                            if (data.Code == 0) {
                                mview.control.tips("已拒绝");
                                pagedata.reload();
                            }
                            else {
                                mview.control.tips(data.Message);
                            }
                        }
                    });
                });
            },
            detail: function (id) {
                mview.view.load('/views/module/friend/detail.html', {
                    id: id
                });
            },
            //加载更多
            more: function () {
                pagedata.request.page += 1;
                mview.socket.send({
                    data: {
                        method: "VIEW_FRIEND_APPLYLISTS",
                        page: pagedata.request.page,
                        part: 1
                    },
                    success: function (json) {
                        if (json.Code == 0 && json.Data.datas.length > 0) {
                            for (var i in json.Data.datas) {
                                var data = json.Data.datas[i];
                                mview.vue.stage.$data.bag.dataend = json.Data.dataend;
                                mview.vue.stage.$data.bag.datas.push(data);
                            }
                        }
                    }
                });
            }
        }
    }
    mview.view.chlid.init(pagedata);
</script>